package com.example.cofeed.adapter;

import com.blankj.utilcode.util.ObjectUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.cofeed.R;
import com.example.cofeed.entity.City;

/**
 * Created by mqwang on 2017/9/26.
 */

public class SelectCityAdapter extends BaseQuickAdapter<City, BaseViewHolder> {

    public SelectCityAdapter() {
        super(R.layout.item_select_city_list);
    }

    @Override
    protected void convert(BaseViewHolder helper, final City item) {

        if (item.selected == 0){
            helper.setImageResource(R.id.push_switch, R.mipmap.closebutn);
        } else{
            helper.setImageResource(R.id.push_switch, R.mipmap.openbutn);
        }

        helper.setText(R.id.name_tv, item.city);
        if (item.price > 0){
            helper.setText(R.id.price_tv, "(¥" + item.price + "元/月)");
        }else {
            helper.setText(R.id.price_tv, "");
        }

    }


    public void setSelect(City select){
        if (select.selected == 0) {
            select.selected = 1;
        } else {
            select.selected = 0;
        }
        notifyDataSetChanged();
    }

}
